package com.lagou.multipartdatasource.controller;

import com.lagou.multipartdatasource.aop.DataAnno;
import com.lagou.multipartdatasource.domain.Student;
import com.lagou.multipartdatasource.service.StudentService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("student")
public class StudentController {

    @Resource
    private StudentService studentService;


    @DataAnno("read")
    @GetMapping("getStudents")
    public List<Student> getStudents(){
        return  studentService.getStudents();
    }

    @GetMapping("create")
    @DataAnno("write")
    public  String createAStudent(Student student){
        studentService.createAStudent(student);
        return "创建成功";
    }
}
